Skip to content

[Backport v4.3-branch] drivers: i2c: i2c_dw: fix target-mode ISR state races and missing START_DET unmask#111414

Open
d3zd3z wants to merge 1 commit into
v4.3-branchfrom
backport-107537-to-v4.3-branch
Open

[Backport v4.3-branch] drivers: i2c: i2c_dw: fix target-mode ISR state races and missing START_DET unmask#111414
d3zd3z wants to merge 1 commit into
v4.3-branchfrom
backport-107537-to-v4.3-branch

Conversation

@d3zd3z

@d3zd3z d3zd3z commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Backport of the fix from #107537 to v4.3-branch.

Fixes: #111412

…tate

The target ISR gates write_requested() on `dw->state != CMD_SEND` so
that back-to-back rx_full interrupts during a single write do not
re-enter the callback. However, dw->state is only transitioned back
to READY on stop_det. If the STOP interrupt is lost (glitch, bus
reset, another master drives STOP while we are servicing the ISR),
or if the master issues a repeated START with the same direction
(WRITE-Sr-WRITE, which is legal in I2C), the state stays CMD_SEND
forever and write_requested() is never called again for the rest of
the target's life.

i2c_dw_slave_read_clear_intr_bits() already handles start_det by
resetting state to READY, but START_DET is not in the enabled
interrupt mask in i2c_dw_slave_register(), so that path is dead code.

Unmask START_DET so the boundary of every new (re)START on the bus
is observed and state is correctly reset before the rx_full handler
decides whether to call write_requested().

Signed-off-by: Sudarshan Iyengar <sudarshan.iyengar@alifsemi.com>
Copilot AI review requested due to automatic review settings June 16, 2026 15:54
@d3zd3z d3zd3z added the Backport Backport PR and backport failure issues label Jun 16, 2026
@github-project-automation github-project-automation Bot moved this to To do in Backports Jun 16, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Backports a DesignWare I2C target (slave) fix onto v4.3-branch by enabling START condition detection interrupts so the slave state machine can reset on fresh START conditions, aligning behavior with the I2C target API contract described in the linked issue/PR.

Changes:

  • Unmasks START_DET in the slave-mode interrupt mask (i2c_dw_slave_register()).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread drivers/i2c/i2c_dw.c
Comment on lines +1145 to 1148
write_intr_mask(DW_INTR_MASK_RX_FULL | DW_INTR_MASK_RD_REQ |
DW_INTR_MASK_TX_ABRT | DW_INTR_MASK_STOP_DET |
DW_INTR_MASK_START_DET,
reg_base);
@sonarqubecloud

Copy link
Copy Markdown

@dkalowsk dkalowsk added this to the v4.3.1 milestone Jun 16, 2026
@jhedberg jhedberg moved this from To do to Ready in Backports Jun 18, 2026
@teburd teburd changed the title [Backport v4.3-branch] drivers: i2c: i2c_dw: fix slave-mode ISR state races and missing START_DET unmask [Backport v4.3-branch] drivers: i2c: i2c_dw: fix target-mode ISR state races and missing START_DET unmask Jun 23, 2026
@jhedberg jhedberg modified the milestones: v4.3.1, v4.3.2 Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: I2C Backport Backport PR and backport failure issues

Projects

Status: Ready

Development

Successfully merging this pull request may close these issues.

7 participants